package reName;

import java.io.File;

public class RenameDemo implements Runnable {
	String newNames = "";
	int id = 0;
	File oldFile = null;

	public RenameDemo(String newNames, int id, File oldFile) {
		this.newNames = newNames;
		this.id = id;
		this.oldFile = oldFile;
	}

	public void run() {
		String parentPath = oldFile.getParent();
		parentPath = parentPath.replaceAll("\\\\", "/");
		if (!parentPath.endsWith("/")) {
			parentPath += "/";
		}
		if (oldFile.isFile()) {
			String fileName = oldFile.getName();
			String prefix = fileName.substring(fileName.lastIndexOf("."));
			File newFile = new File(parentPath + id + prefix);
			oldFile.renameTo(newFile);
		}

	}

}
